var gulp = require('gulp');
var babel = require('gulp-babel');
var sourcemaps =  require('gulp-sourcemaps');
const paramConfig = {
    source: 'src/**/*.js',
    dest: 'build',
  }
gulp.task('default', function() {
    try{
        var watcher = gulp.watch('./src/**/*.*',['babel-sourcemaps']);
        watcher.on('change', function(event) {
        console.log('File ' + event.path + ' was ' + event.type + ', running tasks...');
        });
    }catch(err){
        
    }
});

gulp.task('babel-sourcemaps', () => {
   try{
    return gulp.src(paramConfig.source)  
    .pipe(sourcemaps.init())
    .pipe(babel())
    .pipe(sourcemaps.write('.'))
    .pipe(gulp.dest(paramConfig.dest))
   }catch(err){
       console.log(err);
   }
  })